<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>计数器</title>
  <link href="./css/index.css" rel="stylesheet">
</head>
<body>


  <div id="app">

    <div class="input-num">
      <button @click="sub">-</button>
      <span>{{ num }}</span>
      <button @click="add">+</button>
    </div>

  </div>
  <!--<script src="http://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>-->
  <script src="js/vue.js"></script>
  <script>
    var vue = new Vue({
      el: "#app",
      data: {
        num: 0
      },
      methods: {
        add: function () {
          if (this.num >= 10) {
            alert("别点了, 最大了 ");
            return;
          }
          this.num += 1;
        },
        sub: function () {
          if (this.num <= 0) {
            alert("别点了, 到底了 ");
            return;
          }
          this.num -= 1;
        }
      }
    });
  </script>
</body>
</html>
